#include <stdio.h>
#include <stdlib.h>

int compare_desc(const void* a, const void* b) 
{
    return (*(int*)b - *(int*)a);
}

int main()
{
    int n, m;
    long long k;
    scanf_s("%d %d %lld", &n, &m, &k);
    char** grid = (char**)malloc(n * sizeof(char*));
    for (int i = 0; i < n; i++)
    {
        grid[i] = (char*)malloc((m + 1) * sizeof(char));
        scanf_s("%s", grid[i]);
    }

    int max_segments = n * m;
    int* arr = (int*)malloc(max_segments * sizeof(int));
    int arr_size = 0;

    for (int j = 0; j < m; j++) 
    {
        int i = 0;
        while (i < n) 
        {
            if (grid[i][j] == 'o') 
            {
                int count = 0;
                while (i < n && grid[i][j] == 'o')
                {
                    count++;
                    i++;
                }
                arr[arr_size++] = count;
            }
            else
            {
                i++;
            }
        }
    }

    if (arr_size == 0) 
    {
        printf("0\n");
        for (int i = 0; i < n; i++) 
        {
            free(grid[i]);
        }
        free(grid);
        free(arr);
        return 0;
    }

    qsort(arr, arr_size, sizeof(int), compare_desc);

    long long rest = k;
    long long score = 0;

    for (int i = 0; i < arr_size; i++)
    {
        if (rest >= arr[i])
        {
            rest -= arr[i];
            score += (arr[i] - 1);
            arr[i] = 0;
        }
    }

    if (rest == 0) 
    {
        printf("%lld\n", score);
        for (int i = 0; i < n; i++)
        {
            free(grid[i]);
        }
        free(grid);
        free(arr);
        return 0;
    }

    long long sum_unselected = 0;
    int unselected_count = 0;
    for (int i = 0; i < arr_size; i++)
    {
        if (arr[i] != 0)
        {
            unselected_count++;
            sum_unselected += arr[i];
        }
    }

    if (unselected_count == 0 || sum_unselected == 0)
    {
        printf("%lld\n", score);
        for (int i = 0; i < n; i++) 
        {
            free(grid[i]);
        }
        free(grid);
        free(arr);
        return 0;
    }

    if (sum_unselected < rest)
    {
        score += (sum_unselected - unselected_count);
        printf("%lld\n", score);
        for (int i = 0; i < n; i++)
        {
            free(grid[i]);
        }
        free(grid);
        free(arr);
        return 0;
    }

    long long s = 0;
    int x = 0;
    for (int i = 0; i < arr_size; i++)
    {
        if (arr[i] == 0) continue;
        x++;
        s += arr[i];
        if (s >= rest) 
        {
            score += (rest - x);
            break;
        }
    }

    printf("%lld\n", score);

    for (int i = 0; i < n; i++) 
    {
        free(grid[i]);
    }
    free(grid);
    free(arr);
    return 0;
}